home *** CD-ROM | disk | FTP | other *** search
/ Best of www.BestZips.com (Collector's Edition) / Best of WWW.BESTZIPS.COM Collector's Edition (JCSM Shareware) (JCS Marketing).ISO / prgtools / prtsut53.zip / SU1SRC.ZIP / FDEMO20.PAS < prev    next >
Pascal/Delphi Source File  |  1996-11-24  |  4KB  |  190 lines

  1. unit Fdemo20;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   StdCtrls, Forms, DBCtrls, DB, Buttons, ExtCtrls, DBTables, Mask, PrnWin,
  8.   CB_Types, DBPrnWin, CB_MFunc;
  9.  
  10. type
  11.   TForm20 = class(TForm)
  12.     ScrollBox: TScrollBox;
  13.     Label1: TLabel;
  14.     EditCustNo: TDBEdit;
  15.     Label2: TLabel;
  16.     EditCompany: TDBEdit;
  17.     Label3: TLabel;
  18.     EditAddr: TDBEdit;
  19.     Label4: TLabel;
  20.     EditAddr2: TDBEdit;
  21.     Label5: TLabel;
  22.     EditCity: TDBEdit;
  23.     Label6: TLabel;
  24.     EditState: TDBEdit;
  25.     Label7: TLabel;
  26.     EditZip: TDBEdit;
  27.     Label8: TLabel;
  28.     EditCountry: TDBEdit;
  29.     DBNavigator: TDBNavigator;
  30.     Panel1: TPanel;
  31.     DataSource1: TDataSource;
  32.     Panel2: TPanel;
  33.     Query1: TQuery;
  34.     Panel3: TPanel;
  35.     ScrollBox1: TScrollBox;
  36.     Label14: TLabel;
  37.     Shape1: TShape;
  38.     Label18: TLabel;
  39.     Label19: TLabel;
  40.     Label28: TLabel;
  41.     Label29: TLabel;
  42.     Label20: TLabel;
  43.     Image1: TImage;
  44.     Memo5: TMemo;
  45.     Memo6: TMemo;
  46.     Memo7: TMemo;
  47.     Edit1: TEdit;
  48.     Preview: TBitBtn;
  49.     PrintAll: TBitBtn;
  50.     Print3: TBitBtn;
  51.     Exit: TBitBtn;
  52.     Panel4: TPanel;
  53.     Panel5: TPanel;
  54.     DBEdit2: TDBEdit;
  55.     DBEdit3: TDBEdit;
  56.     DBEdit4: TDBEdit;
  57.     DBEdit5: TDBEdit;
  58.     DBEdit6: TDBEdit;
  59.     DBEdit7: TDBEdit;
  60.     DBEdit8: TDBEdit;
  61.     Label9: TLabel;
  62.     Label10: TLabel;
  63.     Label11: TLabel;
  64.     DBEdit1: TDBEdit;
  65.     Label12: TLabel;
  66.     DBEdit9: TDBEdit;
  67.     DBEdit10: TDBEdit;
  68.     Label15: TLabel;
  69.     DBEdit11: TDBEdit;
  70.     Label16: TLabel;
  71.     DBEdit12: TDBEdit;
  72.     Label17: TLabel;
  73.     DBEdit13: TDBEdit;
  74.     Label21: TLabel;
  75.     DBEdit14: TDBEdit;
  76.     Label13: TLabel;
  77.     DBEdit15: TDBEdit;
  78.     Label22: TLabel;
  79.     DBPrintWin1: TDBPrintWin;
  80.     procedure FormCreate(Sender: TObject);
  81.     procedure PreviewClick(Sender: TObject);
  82.     procedure ExitClick(Sender: TObject);
  83.     procedure Print3Click(Sender: TObject);
  84.     procedure PrintAllClick(Sender: TObject);
  85.   private
  86.     { private declarations }
  87.   public
  88.     { public declarations }
  89.   end;
  90.  
  91. var
  92.   Form20: TForm20;
  93.  
  94. implementation
  95.  
  96. {$R *.DFM}
  97.  
  98. procedure TForm20.FormCreate(Sender: TObject);
  99. begin
  100.   Query1.Open;
  101. end;
  102.  
  103. { Preview/Print current Record }
  104. procedure TForm20.PreviewClick(Sender: TObject);
  105. begin
  106.     ScrollBox1.VertScrollBar.Position := 0;
  107.     ScrollBox1.HorzScrollBar.Position := 0;
  108.     DBPrintWin1.BeginPrint;
  109.    DBPrintWin1.DrawWindowAt( 0.75, 1.0, ScrollBox1);
  110.     DBPrintWin1.EndPrint;
  111.  
  112. end;
  113.  
  114. procedure TForm20.ExitClick(Sender: TObject);
  115. begin
  116.     Close;
  117. end;
  118.  
  119. { Print all Records from Query}
  120. { Print next 3 Records from Query}
  121. procedure TForm20.Print3Click(Sender: TObject);
  122. var
  123.     Bookmark: TBookmark;
  124.    i: Integer;
  125. begin
  126.     { Make sure the scrollbox is at the top }
  127.     ScrollBox1.VertScrollBar.Position := 0;
  128.     ScrollBox1.HorzScrollBar.Position := 0;
  129.  
  130.    { Set PrintWin to the printer }
  131.     DBPrintWin1.OutputTo := poPrinter;
  132.  
  133.  
  134.     { Mark the current record }
  135.    Bookmark := Query1.GetBookmark;
  136.  
  137.    { Print next 3 records }
  138.    for i := 1 to 3 do begin
  139.         DBPrintWin1.BeginPrint;
  140.        DBPrintWin1.DrawWindowAt( 0.75, 1.0, ScrollBox1);
  141.         DBPrintWin1.EndPrint;
  142.       Query1.Next;
  143.    end;
  144.  
  145.    { Return to original record and free the bookmark}
  146.    Query1.GotoBookmark (Bookmark);
  147.    Query1.FreeBookmark (Bookmark);
  148.  
  149.    { Reset to print to the Viewer }
  150.     DBPrintWin1.OutputTo := poViewer;
  151.  
  152. end;
  153.  
  154. procedure TForm20.PrintAllClick(Sender: TObject);
  155. var
  156.     Bookmark: TBookmark;
  157.    i: Integer;
  158. begin
  159.     { Make sure the scrollbox is at the top }
  160.     ScrollBox1.VertScrollBar.Position := 0;
  161.     ScrollBox1.HorzScrollBar.Position := 0;
  162.  
  163.    { Set PrintWin to the printer }
  164.     DBPrintWin1.OutputTo := poPrinter;
  165.  
  166.  
  167.     { Mark the current record }
  168.    Bookmark := Query1.GetBookmark;
  169.  
  170.    { Go to the first record }
  171.    Query1.First;
  172.  
  173.  
  174.    { Print all records }
  175.    while not Query1.Eof do begin
  176.         DBPrintWin1.BeginPrint;
  177.        DBPrintWin1.DrawWindowAt( 0.75, 1.0, ScrollBox1);
  178.         DBPrintWin1.EndPrint;
  179.       Query1.Next;
  180.    end;
  181.  
  182.    { Return to original record and free the bookmark}
  183.    Query1.GotoBookmark (Bookmark);
  184.    Query1.FreeBookmark (Bookmark);
  185.  
  186.    { Reset to print to the Viewer }
  187.     DBPrintWin1.OutputTo := poViewer;
  188. end;
  189.  
  190. end.